<?php
/**
 * Created by PhpStorm.
 * User: sqq
 * Date: 2018/07/27
 * Time: 10:09
 * Description：3M活动
 */

class Activity_3MController extends BaseController {

   /*
    * @Author:      sqq
    * @DateTime:    2018-07-17 10:10:32
    * @Description: 3M活动统计分享次数
    * */
    public function index(){

        do {

            $sql = Activity_3M::first();
            if(!is_null($sql)){
                $sql->num += 1;
                $sql->updated_at = date("Y-m-d H:i:s",time());
            }else{
                $sql = new Activity_3M();
                $sql->num = 1;
                $sql->created_at = date("Y-m-d H:i:s",time());
                $sql->updated_at = date("Y-m-d H:i:s",time());
            }
            if($sql->save()){
                $response = array('code' => 0, 'msg' => 'ok');
            }else{
                $response = array('code' => 1000, 'msg' => '操作失败');
            }

        } while (false);
        Log::info("info", array("system" => "activity" ,"event" => "/Activity_3M/index", 'input' =>Input::all() ,"output" => $response));
        return json_encode($response);

    }

}